<%@ page language="java" import="java.util.*,com.css.vo.Employee" pageEncoding="UTF-8"%>
<%@ page import="com.css.dao.*,com.css.dao.impl.*"%>
<%@ page import="org.springframework.context.*,org.springframework.context.support.*"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>员工信息管理</title>
  <link rel="stylesheet" href="./../styles.css">
</head>
<body>
  <header>
    <h1>员工信息管理</h1>
    <nav>
      <ul> 
      	<li><a href="./../index.jsp">主页</a></li>
        <li><a href="getList.action">系统管理</a></li>
        <li><a href="../Customer/customer-management.jsp">客户信息管理</a></li>
        <li><a href="../Car/car-management.jsp">汽车信息管理</a></li>
        <li><a href="../Employee/employee-management.jsp">员工信息管理</a></li>
        <li><a href="../Sale/sales-management.jsp">销售信息管理</a></li>
      </ul>
     </nav>
  </header>

  <div class="content">
    <h2>员工信息列表</h2>
    <!-- 新增按钮 -->
    <button onclick="location.href='add-employee.jsp'">新增员工</button>
    <table>
      <thead>
        <tr>
          <th>员工ID</th>
          <th>姓名</th>
          <th>性别</th>
          <th>生日</th>
          <th>电话</th>
          <th>职位</th>
          <th>入职时间</th>
          <th>离职时间</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <% 
          // 获取汽车数据
          ApplicationContext myaApplicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
  		  IEmployeeDAO employeeDAO = (IEmployeeDAO)myaApplicationContext.getBean("employeeDAO");
          List<Employee> employeeList = employeeDAO.findAllEmployee();
          if (employeeList != null && !employeeList.isEmpty()) {
              for (Employee employee : employeeList) {
        %>
        <tr>
          <td><%= employee.getEmployeeId() %></td>
          <td><%= employee.getEmployeeName() %></td>
          <td><%= employee.getGender() %></td>
          <td><%= employee.getBirthDate() %></td>
          <td><%= employee.getPhone() %></td>
          <td><%= employee.getPosition() %></td>
          <td><%= employee.getEnterDate() %></td>
          <td><%= employee.getLeaveDate() %></td>
          <td>
          	<form action="updateEmployeeView.action" method="post">
    			<input type="hidden" name="employeeId" value="<%= employee.getEmployeeId() %>">
    			<button type="submit">修改</button>
  			</form>
            <form action="deleteEmployee.action" method="post" onsubmit="return confirm('确定删除该员工信息吗?');">
    			<input type="hidden" name="employeeId" value="<%= employee.getEmployeeId() %>">
    			<button type="submit">删除</button>
  			</form>
          </td>
        </tr>
        <% 
              }
          } else {
        %>
        <tr>
          <td colspan="9" style="text-align: center;">暂无数据</td>
        </tr>
        <% } %>
      </tbody>
    </table>
  </div>
</body>
</html>
